<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
		
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Movie Catalog</title>
		<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen" />
		<script src="http://code.jquery.com/jquery-latest.js"></script>
		<script src="bootstrap/js/bootstrap.min.js"></script>
		
		<style>
			body {
				padding-top: 60px;
				/* 60px to make the container go all the way to the bottom of the topbar */
			}
		</style>
	</head>
	
	<body onload="displayResult()">
		<div class="navbar navbar-inverse navbar-fixed-top">
			<div class="navbar-inner">
				<div class="container">
					<a class="brand" href="#">RentDVD</a>
					<ul class="nav">
						<li><a href="catalog.jsp">Movie Catalog</a></li>
						<li><a href="recommendMovie.jsp">Recommend Movie</a></li>
						<li class="active"><a href="">History</a></li>
					</ul>
					<ul class="nav pull-right">
						<li><button class="btn btn-danger" onclick="logout();">Logout</button></li>
					</ul>
				</div>
			</div>
		</div>
		
		<div class="container">
			<div id="movieTable">
				<h2>History</h2>
			</div>
			
		</div>
		
		<script>
			function loadXMLDoc(dname) {
				if (window.XMLHttpRequest) {
					xhttp = new XMLHttpRequest();
				} else {
					xhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				
				xhttp.open("GET", dname, false);
				xhttp.send("");
				return xhttp.responseXML;
			}
			
			function displayResult() {
				xsl = loadXMLDoc("movies.xsl");
				xml = loadXMLDoc("/RentDVDsClient/movie?getHistory");
				// code for IE
				if (window.ActiveXObject) {
					ex = xml.transformNode(xsl);
					document.getElementById("movieTable").innerHTML = ex;
				} else if (document.implementation && document.implementation.createDocument) {
					// code for Mozilla, Firefox, Opera, etc.
					xsltProcessor = new XSLTProcessor();
					xsltProcessor.importStylesheet(xsl);
					resultDocument = xsltProcessor.transformToFragment(xml, document);
					document.getElementById("movieTable").appendChild(resultDocument);
				}
                $('td:nth-child(6),th:nth-child(6)').hide();
			}
			
			function logout() {
				var form = document.createElement('form');
				form.setAttribute('method', 'post');
				form.setAttribute('action', 'logout');
				form.style.display = 'hidden';
				document.body.appendChild(form);
				form.submit();
			}
		</script>
	</body>
</html>